package org.grow.later;

public  class Diff {

    private int n = 10000;

    private SimpleFunction simpleFunction;

    public Diff(SimpleFunction simpleFunction) {
        this.simpleFunction = simpleFunction;
    }

    public double cal(double start, double end){
       return this.cal(start,end,n);
    }
    public double cal(double start, double end,int n){

        double deltaX = (end-start)/n;
        double sum = 0;
        for (int i = 0; i < n; i++) {
            sum += deltaX * simpleFunction.f(start + deltaX * i);

        }
      //  this.persistInfo(start,end,sum);
        return sum;
    }
    //protected abstract void persistInfo(double start, double end, double sum);


}
